package com.example.demoreqinterceptionapi.controller;

import com.example.demoreqinterceptionapi.result.Result;
import com.example.demoreqinterceptionapi.vo.InfoVO;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * api接口
 *
 * @author Lv
 * @date 2024/10/22
 */
@RestController
@RequestMapping("/api")
public class ApiController {
    /**
     * 获取信息
     *
     * @return
     */
    @PostMapping("/get_info")
    public Result<?> getInfo() {
        return Result.success(InfoVO.builder().name("Richard").age(26).occupation("Programmer").build());
    }

    @Value("${spring.application.name}")
    private String serviceName;

    /**
     * 获取服务名称
     *
     * @return
     */
    @PostMapping("/get_service_name")
    public Result<?> getServiceName() {
        return Result.success(serviceName);
    }
}
